/**
 * 
 */
package dbexel.system.tools;

import dbexel.model.mapping.AttributeValue;
import dbexel.model.mapping.WorkSheet;
import dbexel.model.mapping.WorkSheet_Attribute;
import dbexel.model.mapping.WorkSheet_Entry;

/**
 * @author gandomi
 *
 */
public class DBExelTestTools {

	/**
	 * This method returns a test worksheet with fake id's
	 * @param in_name
	 * @return
	 */
	public static WorkSheet fetchTestWorkSheet(String in_name) {
		WorkSheet l_workSheet = new WorkSheet(in_name);

		WorkSheet_Attribute l_wsAttr1 = new WorkSheet_Attribute("Column 3");

		WorkSheet_Attribute l_wsAttr2 = new WorkSheet_Attribute("Column 5");

		WorkSheet_Attribute l_wsAttr3 = new WorkSheet_Attribute("Column 7");

		WorkSheet_Attribute l_wsAttr4 = new WorkSheet_Attribute("Column 11");

		WorkSheet_Attribute l_wsAttr5 = new WorkSheet_Attribute("Column 13");

		// Add attributes
		l_workSheet.attachAttribute(l_wsAttr1);
		l_workSheet.attachAttribute(l_wsAttr2);
		l_workSheet.attachAttribute(l_wsAttr3);
		l_workSheet.attachAttribute(l_wsAttr4);
		l_workSheet.attachAttribute(l_wsAttr5);

		// Add Antries
		l_workSheet.addEntry(new WorkSheet_Entry());
		l_workSheet.addEntry(new WorkSheet_Entry());

		// Fill the entries
		l_workSheet
				.getEntries()
				.get(0)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr1, "Attr1 valA"));
		l_workSheet
				.getEntries()
				.get(0)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr2, "Attr2 valB"));
		l_workSheet
				.getEntries()
				.get(0)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr3, "Attr3 valC"));
		l_workSheet
				.getEntries()
				.get(0)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr4, "Attr4 valD"));
		l_workSheet
				.getEntries()
				.get(0)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr5, "Attr5 valE"));

		l_workSheet
				.getEntries()
				.get(1)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr1, "Attr1 valZ"));
		l_workSheet
				.getEntries()
				.get(1)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr2, "Attr2 valY"));
		l_workSheet
				.getEntries()
				.get(1)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr3, "Attr3 valX"));
		l_workSheet
				.getEntries()
				.get(1)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr4, "Attr4 valW"));
		l_workSheet
				.getEntries()
				.get(1)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr5, "Attr5 valV"));

		return l_workSheet;
	}

	
	/**
	 * This method returns a test worksheet with fake id's
	 * @param in_name
	 * @return
	 */
	public static WorkSheet fetchTestWorkSheetWithId(String in_name) {
		WorkSheet l_workSheet = new WorkSheet(in_name);
		l_workSheet.setWs_Id(new Long(17));

		WorkSheet_Attribute l_wsAttr1 = new WorkSheet_Attribute("Column 3");
		l_wsAttr1.setAttrId(new Long(8));
		WorkSheet_Attribute l_wsAttr2 = new WorkSheet_Attribute("Column 5");
		l_wsAttr2.setAttrId(new Long(9));
		WorkSheet_Attribute l_wsAttr3 = new WorkSheet_Attribute("Column 7");
		l_wsAttr3.setAttrId(new Long(23));
		WorkSheet_Attribute l_wsAttr4 = new WorkSheet_Attribute("Column 11");
		l_wsAttr4.setAttrId(new Long(27));
		WorkSheet_Attribute l_wsAttr5 = new WorkSheet_Attribute("Column 13");
		l_wsAttr5.setAttrId(new Long(31));

		// Add attributes
		l_workSheet.attachAttribute(l_wsAttr1);
		l_workSheet.attachAttribute(l_wsAttr2);
		l_workSheet.attachAttribute(l_wsAttr3);
		l_workSheet.attachAttribute(l_wsAttr4);
		l_workSheet.attachAttribute(l_wsAttr5);

		// Add Antries
		l_workSheet.addEntry(new WorkSheet_Entry());
		l_workSheet.addEntry(new WorkSheet_Entry());

		l_workSheet.getEntries().get(0).setEntryId(new Long(37));
		l_workSheet.getEntries().get(1).setEntryId(new Long(41));

		// Fill the entries
		l_workSheet
				.getEntries()
				.get(0)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr1, "Attr1 valA"));
		l_workSheet
				.getEntries()
				.get(0)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr2, "Attr2 valB"));
		l_workSheet
				.getEntries()
				.get(0)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr3, "Attr3 valC"));
		l_workSheet
				.getEntries()
				.get(0)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr4, "Attr4 valD"));
		l_workSheet
				.getEntries()
				.get(0)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr5, "Attr5 valE"));

		l_workSheet
				.getEntries()
				.get(1)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr1, "Attr1 valZ"));
		l_workSheet
				.getEntries()
				.get(1)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr2, "Attr2 valY"));
		l_workSheet
				.getEntries()
				.get(1)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr3, "Attr3 valX"));
		l_workSheet
				.getEntries()
				.get(1)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr4, "Attr4 valW"));
		l_workSheet
				.getEntries()
				.get(1)
				.attachAttributeValue(
						new AttributeValue(l_wsAttr5, "Attr5 valV"));

		return l_workSheet;
	}
	
}
